﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.LongER.Framework.Utils;
using Com.LongER.Business.ZAH002.ZAH002DSTableAdapters;

namespace Com.LongER.Business.ZAH002
{
    /// <summary>
    /// 
    /// </summary>
    public class CZAH002:ABussinessBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strUserId"></param>
        /// <param name="strPassword"></param>
        /// <returns></returns>
        public Boolean ChangeUserPassword(String strUserId,String strNewPassword)
        {
            String connectionString = ConnectionStringUtil.GetConnectionString();
            M_USERTableAdapter ta = new M_USERTableAdapter(connectionString);

           int result = ta.UpdatePasswordByUserId(strNewPassword, strUserId);
           ta.Connection.Close();
           
           if (result > 0) return true;

           return false;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="strUserId"></param>
        /// <param name="strPassword"></param>
        /// <returns></returns>
        public ZAH002DS.M_USERDataTable GetUser(String strUserId, String strPassword)
        {
            String connectionString = ConnectionStringUtil.GetConnectionString();
            M_USERTableAdapter ta = new M_USERTableAdapter(connectionString);

            ZAH002DS.M_USERDataTable tb = ta.GetDataByUserIdAndPassword(strUserId, strPassword);
            ta.Connection.Close();
            return tb;

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="strUserId"></param>
        /// <param name="strPassword"></param>
        /// <returns></returns>
        public ZAH002DS.M_USERDataTable GetUser(String strUserId)
        {
            String connectionString = ConnectionStringUtil.GetConnectionString();
            M_USERTableAdapter ta = new M_USERTableAdapter(connectionString);

            ZAH002DS.M_USERDataTable tb = ta.GetDataByUserId(strUserId);
            ta.Connection.Close();
            return tb; 

        }
    }
}
